set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT name FROM sysobjects WHERE name = 'mov_getMoviesByGenre' AND type = 'P')
DROP PROCEDURE mov_getMoviesByGenre
GO




-- =============================================
-- Modified:    Sourov Chatterjee
-- Create date: 6/3/2011
-- Description:	This procedure gets movies for a director 

-- =============================================
CREATE PROCEDURE [dbo].[mov_getMoviesByGenre] 	
@movie_genre_ID int = 5
AS
BEGIN

	--SELECT @searchtext = '%' + RTRIM(@searchtext) + '%'
	select m.movie_id, m.movie_name, (md.movie_dir_fname + ' ' + md.movie_dir_lname)as dir , mg.movie_genre as genre,
    m.movie_image, m.short_desc 
    from movie m JOIN movie_director md 
    on m.movie_dir_id = md.movie_dir_id
    JOIN movie_genre mg 
    ON m.movie_genre_id = mg.movie_genre_id

    where m.movie_genre_id =@movie_genre_ID

--select * from movie
	

END

